package org.jeecg.modules.health_records.past_medical.service.impl;

import org.jeecg.modules.health_records.past_medical.entity.PastMedicalInfo;
import org.jeecg.modules.health_records.past_medical.mapper.PastMedicalInfoMapper;
import org.jeecg.modules.health_records.past_medical.service.IPastMedicalInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 既往病史表
 * @Author: jeecg-boot
 * @Date:   2025-06-25
 * @Version: V1.0
 */
@Service
public class PastMedicalInfoServiceImpl extends ServiceImpl<PastMedicalInfoMapper, PastMedicalInfo> implements IPastMedicalInfoService {
    @Autowired
    private PastMedicalInfoMapper pastMedicalInfoMapper;
    /**按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<PastMedicalInfo> queryByRecordId(PastMedicalInfo pastMedicalInfo) {
        return pastMedicalInfoMapper.queryByRecordId(Long.valueOf(pastMedicalInfo.getRecordid()),pastMedicalInfo.getIdNumber());

    }
    /**电子病历信息查询接口（查询时间最新的那条数据）--按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<PastMedicalInfo> queryElecRecord(PastMedicalInfo pastMedicalInfo) {
        return pastMedicalInfoMapper.queryElecRecord(Long.valueOf(pastMedicalInfo.getRecordid()),pastMedicalInfo.getIdNumber());

    }
    //新规则查询当下时间往前12个月的就诊数据作为电子病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<PastMedicalInfo> newQueryElecRecord(PastMedicalInfo healthNeurIndexInf) {
        return pastMedicalInfoMapper.newQueryElecRecord(Long.valueOf(healthNeurIndexInf.getRecordid()),healthNeurIndexInf.getSeeId(),healthNeurIndexInf.getIdNumber());

    }

    //新规则：除去当下时间往前12个月的就诊数据，剩下的数据为既往病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<PastMedicalInfo> newQueryPastRecord(PastMedicalInfo healthNeurIndexInf) {
        return pastMedicalInfoMapper.newQueryPastRecord(Long.valueOf(healthNeurIndexInf.getRecordid()),healthNeurIndexInf.getSeeId(),healthNeurIndexInf.getIdNumber());

    }
    
}
